<template>
	<div class="home">
		<userHead active="home" :showAction="true"></userHead>
		<div class="home_main">
			<div class="hm_left">
             
				<div class="reword">
                    <div class="rw_title">
						<span>控制台</span>
					</div>
					<div class="rw_list">
						<div class="rwl_main">
							<div class="rwl_title" @click="showResume = !showResume">
								<div class="rwlt_icon">
									<i class="el-icon-arrow-down" v-if="showResume"></i>
									<i class="el-icon-arrow-right" v-else></i>
								</div>
								<div class="rwlt_name">
									<span>简历管理</span>
								</div>
							
							</div> 
							<div class="rwl_list">
								<div class="rwll_div" @click="setActiveContent(0)" :class="{selectrwll:activeContent==0}">
									<span>完整简历</span>
								</div>
								<div class="rwll_div" @click="setActiveContent(1)" :class="{selectrwll:activeContent==1}">
									<span>极简简历</span>
								</div>
								<div class="rwll_div" @click="setActiveContent(2)" :class="{selectrwll:activeContent==2}">
									<span>公开设置</span>
								</div>
								<div class="rwll_div">
									<span>职业认证</span>
								</div>
								<div class="rwll_div" @click="setActiveContent(3)" :class="{selectrwll:activeContent==3}">
									<span>简历被查看记录</span>
								</div>
							</div>
						</div>
						<div class="rwl_main">
							<div class="rwl_title">
								<div class="rwlt_icon" @click="showTag = !showTag">
									<i class="el-icon-arrow-down" v-if="showTag"></i>
									<i class="el-icon-arrow-right" v-else></i>
								</div>
								<div class="rwlt_name">
									<span>求职管理</span>
								</div>
								
							</div>
							<div class="rwl_list" v-if="showTag">
								<div class="rwll_div" @click="setActiveUrl('/user/post',0)">
									<span>检索岗位</span>
								</div>
								<div class="rwll_div" @click="setActiveUrl('/user/post',1)">
									<span>接触中的岗位</span>
								</div>
								<div class="rwll_div" @click="setActiveUrl('/user/post',2)">
									<span>推荐/邀约的岗位</span>
								</div>
								
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="hm_right">
				

				<div class="hmr_content" v-if="activeContent==0">
					<biographical-notes-add ref="biographical" v-if="userMainReme.id"
                        @updateResumeImg="updateResumeImg" @saveSume="saveSume" :userSumeContent="userSumeContent"
                        :userMainReme="userMainReme" @refreshReme="refreshReme"></biographical-notes-add>
				</div>

				<div class="hmr_content" v-if="activeContent==1">
					<biographical-notes-Litter ref="biographical" v-if="userMainReme.id"
                        @updateResumeImg="updateResumeImg" @saveSume="saveSume" :userSumeContent="userSumeContent"
                        :userMainReme="userMainReme" @refreshReme="refreshReme"></biographical-notes-Litter>
				</div>

                <div class="hmr_content" v-if="activeContent==2">
                    <div class="resume-item">
                        <div class="register-tag" style="margin-top: 30px;">简历对企业</div>
                        <div class="form-group" style="display: inline-block;width: 100%;">
                            <label class="register-form-label control-label" style="width: 170px;">开放范围</label>
                            <div class="register-form-control">
                                <el-select v-model="publicset" placeholder="请选择"
                                    style="width: 400px;">
                                    <!-- <el-option v-for="item in dictInfo.yn" :key="item.value" :label="item.label"
                                        :value="item.value">
                                    </el-option> -->
                                    <el-option  label="公开，可以被任何企业下载"
                                        value="1">
                                    </el-option>
                                    <el-option  label="公开，但对以下企业保密"
                                        value="2">
                                    </el-option>
                                    <el-option  label="封闭，不被任何企业检索到"
                                        value="3">
                                    </el-option>
                                </el-select>

                                <el-input placeholder="请填写保密的企业" v-if="publicset==2" style="width: 400px;margin-left: 15px;"></el-input>

                            </div>
                        </div>
                        <div class="register-tag" >简历展现方式</div>
                        <div class="form-group" style="display: inline-block;width: 100%;">
                            <label class="register-form-label control-label" style="width: 170px;">自己投递岗位</label>
                            <div class="register-form-control">
                                <el-select v-model="form.next" placeholder="请选择"
                                    style="width: 400px;">
                                    <!-- <el-option v-for="item in dictInfo.yn" :key="item.value" :label="item.label"
                                        :value="item.value">
                                    </el-option> -->
                                    <el-option  label="完整方式"
                                        value="1">
                                    </el-option>
                                    <el-option  label="极简方式"
                                        value="2">
                                    </el-option>
                                  
                                </el-select>

                               

                            </div>
                        </div>
                        <div class="form-group" style="display: inline-block;width: 100%;">
                            <label class="register-form-label control-label" style="width: 170px;">被推荐的岗位</label>
                            <div class="register-form-control">
                                <el-select v-model="form.dsa" placeholder="请选择"
                                    style="width: 400px;">
                                    <!-- <el-option v-for="item in dictInfo.yn" :key="item.value" :label="item.label"
                                        :value="item.value">
                                    </el-option> -->
                                    <el-option  label="完整方式"
                                        value="1">
                                    </el-option>
                                    <el-option  label="极简方式"
                                        value="2">
                                    </el-option>
                                  
                                </el-select>

                               

                            </div>
                        </div>

                         <div class="register-tag" style="clear:both;">屏蔽的公司
                        </div>
                        <div class="conditionNext" >
                            <div class="form-group fixwcontrol2" style="width: 100%;display: inline-block;">
                                <label class="register-form-label control-label fontclass" style="width:170px">公司名称：</label>
                                <div class="register-form-control">
                                    
                                    <input id="professionalneed" style="width:900px" type="text" class="form-control"
                                        placeholder="不限" v-model="form.professionalRequirements">
                                    
                                </div>
                            </div>
                            
                        </div>

                         <div class="register-action">
                            <input type="button" value="保存设置" class="btn btn-primary btn-lg savejob"
                                @click="savePost('2')">
                           
                        </div>

                    </div>
                </div>

                <div class="hmr_content" v-if="activeContent==3">
                    <table class="table table-horborder">
                    <tbody>
                        <tr>
                            <th style="width: 320px">公司</th>
                            <th>被查看时间</th>
                        </tr>
                        
                            <tr>
                                <td>王凯测试公司</td>
                                <td>
                                   2025-09-27 16:56
                                </td>
                            </tr>
                    


                    </tbody>
                </table>
                </div>
			</div>
		</div>
		<div class="post_bottom">
			<post-footer-main-vue></post-footer-main-vue>
		</div>
		 
	</div>
</template>

<script>
// @ is an alias to /src
import userHead from '@/components/userHead.vue';
import homeapi from '@/api/api.js'
import userImg from '@/assets/imgs/ai_logo.jpg'
 import postFooterMainVue from '@/components/postFooterMain.vue';
 import biographicalNotesAdd from '@/views/biographicalNotes/add.vue'
 import biographicalNotesLitter from '@/views/biographicalNotes/litterSume.vue'
import { refresh } from 'less';
import until from '@/api/until';
export default {
	name: 'HomeView',
	data() {
		return {
			 companyInfo: {},
            activeName:"first",
            input: "",
            value: "",
            tableData: [],
            totalInfo: {},

            showDel: true,
            showTag: true,
            showPost: true,
            showResume: true,
            showTotal: true,
            showMoney: true,

            dictInfo: {},
            companyList: [],
            haveAdd: false,
            haveEdit: false,
            selectPost: [],
            postForm: {},
            reword: '',
            name: "",
            status: '1',
            showEidt: false,

            userReme: {},
            userMainReme: {},
            userSumeContent: {},
            userImg: userImg,
			activeContent:0,
            publicset:"1",
            form:{
                next:''
            }
		}
	},
	components: {
		userHead,postFooterMainVue,biographicalNotesAdd,biographicalNotesLitter
	},
	mounted() {
		
		this.getSumeContent();
        this.getDictList();

        this.getLitterSume();

        let type=this.$route.query.type;
        if(type){
            this.activeContent=type;
        }
        

	},
	beforeDestroy(){
		until.setCookie("isEdit",'')
	},
	methods: {
		setActiveContent(type){
			this.activeContent=type
		},
		setActiveUrl(url,type){
			this.$router.push(url+"?type="+type)
		},
		 //获取极简简历
        async getLitterSume() {
            let data = await homeapi.getLitterSume();
            if (data.code == 200) {
				// data.result.resumeSkills.resumeSkillLanguageList.map(res => {
                //     res.showEdit = false;
                // })

                // data.result.resumeEducations.map(res => {
                //     res.showEdg = false;
                // })
                // data.result.resumeDetails.map(res => {
                //     res.showMore = false;
                //     res.isNow = false
                //     if (res.workingEnd == "9999-12-31") {
                //         res.isNow = true;
                //     }
                //     res.resumePostList.map(json => {
                //         json.isNow = false
                //         json.showChild = false
                //         if (json.workingEnd == '9999-12-31') {
                //             json.isNow = true
                //         }
                //     })
                // })
                this.userReme = data.result
				this.userMainReme = data.result;
				//  setTimeout(() => {
                //     if (this.$refs.biographical && this.$refs.biographical.workplace.length > 0) {
                //         this.$refs.biographical.getForm(this.userSumeContent);
                //     }
                //     this.$forceUpdate();
                // })

            }
            // if(data.)
        },
        //获取完整简历
        async getMainSume() {
            let data = await homeapi.getMainSume();
            if (data.code == 200) {

                data.result.resumeSkills.resumeSkillLanguageList.map(res => {
                    res.showEdit = false;
                })

                data.result.resumeEducations.map(res => {
                    res.showEdg = false;
                })
                data.result.resumeDetails.map(res => {
                    res.showMore = false;
                    res.isNow = false
                    if (res.workingEnd == "9999-12-31") {
                        res.isNow = true;
                    }
                    res.resumePostList.map(json => {
                        json.isNow = false
                        json.showChild = false
                        if (json.workingEnd == '9999-12-31') {
                            json.isNow = true
                        }
                    })
                })
                this.userMainReme = data.result;

                setTimeout(() => {
                  
                    this.$refs.biographical.getForm(this.userSumeContent);
                    
                    this.$forceUpdate();
                })




            }
        },
        //获取编辑简历
        async getSumeContent() {
            let data = await homeapi.getSumeContent();
            if (data.code == 200) {
                data.result.resumeDetailList.map((res, index) => {
                    res.isNow = false
                    res.resumePostList.map((json, jsonindex) => {
                        json.postWorkPlace = [];
                        json.isNow = false
                        json.showChild = false

                    })

                })
                this.userSumeContent = data.result;

                this.getMainSume();

            }
        },

        //更新头像
        async updateResumeImg(form) {
            let data = await homeapi.updateResumeImg(form)
            if (data.code == 200) {
                this.$toast("更改成功")
                this.getSumeContent();
                this.getLitterSume();

            }
        },


        showEditReme() {
            until.setCookie("isEdit", true)
            this.getSumeContent();
            this.showEidt = true;
        },

        handleSelectionChange(val) {
            this.selectPost = val;
        },
        //获取数据字典
        async getDictList() {
            let data = await homeapi.getDictList();
            if (data.code == 200) {
                this.dictInfo = data.result
            }
        },
        //保存简历
        async saveSume(form) {
			const loading = this.$loading({
				lock: true,
				text: '',
				spinner: 'el-icon-loading',
				background: 'rgba(0, 0, 0, 0.7)'
			});
            let data = await homeapi.saveSume(form);
            if (data.code == 200) {
				this.getLitterSume();
				loading.close()
                this.getSumeContent();
                this.updateUserInfo(form)
				

            }
        },

        //更新基本信息
        async updateUserInfo(userSume) {
            console.log(this.userMainReme)

            let form = {
                birthday: this.userMainReme.birthday,
                email: this.userMainReme.email,
                idCard: this.userMainReme.idCard,
                img: this.userMainReme.img,
                name: this.userMainReme.name,
                postRank: this.userMainReme.postRank,
                sex: this.userMainReme.sex,
                wechat: this.userMainReme.wechat,
            }
            let data = await homeapi.updateUserInfo(form)
            if (data.code == 200) {

            }
        },

        //刷新简历
        async refreshReme() {
            let data = await homeapi.refreshReme({})
            if (data.code == 200) {
                this.getMainSume();
            }
        },
        //更新简历图片
        async changeFile(e) {
            if (e.target.files.length > 0) {
                let file = e.target.files[0];
                var formData = new FormData();

                formData.append("file", file);
                let data = await homeapi.uploadFile(formData);

                if (data.code == 200) {
                    this.updateResumeImg({ img: data.result.path })
                    // this.form.postImgUrl = data.result.url;
                    // this.form.postImg = data.result.path;
                    // console.log(this.form);
                }
            }
        },
	}
}
</script>
<style>
.el-table th.el-table__cell {
    background: #ebebeb;
}
.el-loading-spinner i{
	color: #409eff;
}
.el-loading-spinner{
	font-size: 80px !important;
}
.el-table thead {
    color: #333333;
    font-weight: bold;
}

.el-table--border .el-table__cell,
.el-table__body-wrapper .el-table--border.is-scrolling-left~.el-table__fixed {
    border-right: 1px solid #ddd;
}

.el-table .el-table__cell {
    padding: 0px !important;
}

.el-table__row .el-table__cell {
    padding: 10px 0 !important;
}
</style>
<style scoped>
.home_main {
    width: 100%;

    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 0 16px;
    box-sizing: border-box;
    height: calc(100vh - 140px);
}

.hm_left {
    width: 180px;
    min-width: 180px;

	height: calc(100vh - 155px);
    border-radius: 0px 0px 0px 0px;

    display: inline-block;
    background: #FFFFFF;
    margin-top: 15px;
    padding-bottom: 30px;
}

.hml_main {
    width: 100%;

    background: #FFFFFF;

    padding: 0 20px;
    padding-bottom: 16px;
    ;
    box-sizing: border-box;

}

.hm_right {
    flex: 1;
    height: 100%;
	margin-top: 15px;
	margin-left: 10px;

}

.hml_div {
    width: 100%;
    display: inline-block;
    margin-top: 16px;
    cursor: pointer;
}

.hmld_head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 13px;
    color: #333333;
    font-weight: bold;
}

.hmld_left {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 12px;
    margin-left: 8px;
}

.hmld_left .iconfont {
    font-size: 14px;
    margin-left: 8px;
    color: #999999;
}

.hml_content {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    line-height: 18px;
    padding-left: 20px;
    box-sizing: border-box;
    margin-top: 6px;
}

.hml_content span:first-child {
    font-size: 12px;
    color: #06c;
}

.hml_content span:last-child {
    font-size: 12px;
    font-weight: bold;
    margin-left: 8px;
}

.hmr_head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-top: 16px;
    background: #FFFFFF;
    padding: 0 16px;
    box-sizing: border-box;
}

.hmrh_div {
    flex: 1;
    height: 40px;
    border-radius: 4px;
    background: #FFFFFF;
    border-radius: 0px 0px 0px 0px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    font-size: 14px;
    color: #333333;
    font-weight: bold;
    line-height: 32px;
    margin-left: 16px;
    cursor: pointer;
}



.hmr_content {
    width: 100%;

    background: #FFFFFF;
    display: inline-block;

    height: calc(100vh - 155px);
    overflow: auto;
   
}

.hmrc_head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 9px;
    padding: 0 32px;
    box-sizing: border-box;
}

.hmrch_left {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.select_div {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-left: 16px;
    font-size: 16px;
}

.select_div_label {
    margin-right: 8px;
}

.hmrch_right {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-top: 15px;
    padding-left: 15px;
    box-sizing: border-box;
}

.hmrchr_div {
    width: 72px;
    height: 34px;
    background: #F5792A;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #FFFFFF;
    margin-right: 16px;
    cursor: pointer;
}

.hmrc_body {
    width: 100%;

    box-sizing: border-box;

}

.reword {
    width: 100%;
    background: #FFFFFF;
    overflow: auto;
    height:100%;
}

.rw_title {
    width: 180px;
    height: 44px;
    background: #F2F2F2;
    border-radius: 0px 0px 0px 0px;
    border: 1px solid #E6E6E6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #3D3D3D;
    font-weight: bold;
}

.rw_list {
    width: 100%;
    display: inline-block;
    padding-left: 10px;
    box-sizing: border-box;
}

.rwl_main {
    width: 100%;
    display: inline-block;
}

.rwl_title {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-top: 10px;
    cursor: pointer;
}

.rwlt_icon i {
    font-size: 14px;
    color: #333333;
}

.rwlt_name {
    font-size: 13px;
    color: #333333;
    font-weight: bold;
    margin-left: 4px;
}

.rwl_list {
    width: 100%;
    display: inline-block;
}

.rwll_div {
    font-size: 12px;
    line-height: 18px;
    color: #06c;
    padding-left: 30px;
    box-sizing: border-box;
    margin-top: 6px;
    cursor: pointer;
}

.rwll_div:hover {
    color: #F5792A;
}

.hmrc_botoom {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.hmrch_left_main {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #333333;
    margin-top: 15px;
    margin-right: 15px;
}



.rwlt_btn {
    width: 72px;
    height: 26px;
    background: #F5792A;
    border-radius: 0px 0px 0px 0px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #FFFFFF;
    margin-left: 28px;
    border-radius: 4px;
}

.rwl_title i {
    font-size: 16px;
    margin-left: 10px;
    color: #333333;
}

.border_div {
    width: 100%;
    height: 15px;
    background: #f8f8f8;
}

.hmrchl_div {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}

.center_div {
    text-align: center;
}

.need_input {
    height: 40px;
    border: 1px solid #DCDFE6;
    text-align: center;
    font-size: 14px;
    border-radius: 2px;
    width: 100%;
}

.post_bottom {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
}

.iconmd {
    display: flex;
}

.selecthmth span {
    color: #06c;
}

.selecthmth span:last-child {
    color: #06c;
}
.select_hmrh{
    background: #F5792A;
    color: #ffff;
}
.personal-rt{
    border: 0px;
}
</style>
<style>
.el-table-column--selection .cell {
    padding: 0px !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.el-table th.el-table__cell>.cell {

    padding-left: 8px;
    padding-right: 5px;
}

.el-table th.el-table__cell.is-leaf .el-checkbox {
    margin-left: 7px;
}

.memberphoto img {
    width: 108px;
    height: 108px;
}

.vitaelink {
    margin-right: 10px;
}

.memberphoto {
    position: relative;
}
.selectrwll span{
	color: #fc7b24;
}
</style>
